package org.example.user.controller;

import cn.hutool.jwt.JWT;
import cn.hutool.jwt.JWTUtil;
import org.example.user.domain.Bankcard;
import org.example.user.domain.Banktype;
import org.example.user.service.BankcardService;
import org.example.user.service.BanktypeService;
import org.example.user.utils.Result;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
@RequestMapping("bank")
public class BankController {
    @Autowired
    private BankcardService bankcardService;
    @Autowired
    private BanktypeService banktypeService;
    @Autowired
    private RedisTemplate redisTemplate;


    //    获取当前用户银行卡列表
    @RequestMapping("myBankCard")
    public Result myBankCard(String token) {
        JWT jwt = JWTUtil.parseToken(token);
        Integer id = (Integer) jwt.getPayload("id");
        List<Bankcard> bankcards = bankcardService.getBankCard(id);
        return Result.success(bankcards);
    }

    //    获取银行列表
    @RequestMapping("bankType")
    public Result bankType() {
        List<Banktype> list = banktypeService.list();
        return Result.success(list);
    }


}
